import {nanoid} from "nanoid"

//定义本地存储的key
const userTempId = "userTempId";

export default function getUserTempId(){
    //1.先判断本地存储中是否存在临时id
    if(localStorage.getItem(userTempId)){
        //有 则返回已经存在的id
        return localStorage.getItem(userTempId)
    }else{
        //没有 新创建随机数
        const id = nanoid();
        localStorage.setItem(userTempId,id)
        return id
    }
}